﻿using System.Web.UI;
using System.Web;
using System.IO;

namespace App_Code
{
    public static class StringExt
    {
        static Control ctrl = new Control();

        public static string WithApo(this string @this)
        {
            return string.Format("'{0}'", @this);
        }

        public static string ToActionImage(this string @this, string theme)
        {
            var nfn = "App_Themes/" + theme + "/images/noimage.png";
            var fn = "App_Themes/" + theme + "/images/" + @this;
            var file = HttpContext.Current.Server.MapPath(fn);
            if (!File.Exists(file)) fn = nfn; 
            return ctrl.ResolveClientUrl(fn);
        }
    }
}